- Look for areas that people do not use cars as much in
- Put more bikes in the areas where there are less people commuting to
work in cars
- Relation between motorized vehicles and bikes
- Parking spaces
- Last mile
- Where best to place bike stations
library(knitr)
library(tidyverse)
library(janitor)
library(lubridate) # because we will probably see some dates
library(here) # more easily access files in your project
library(sf) # working with simple features - geospatial
library(tmap)
library(tidycensus)
bikes = (read.csv(here("data_raw", "202309-capitalbikeshare-tripdata.csv"))) |> clean_names()
racks = st_read((here("data_raw", "Public_Bike_Racks.geojson"))) |> clean_names()
Reading layer `Public_Bike_Racks' from data source `C:\Users\thistljy\Documents\ds241_final\data_raw\Public_Bike_Racks.geojson' using driver `GeoJSON'
Simple feature collection with 3558 features and 2 fields
Geometry type: POINT
Dimension: XY
Bounding box: xmin: -77.1107 ymin: 38.81903 xmax: -76.91907 ymax: 38.98663
Geodetic CRS: WGS 84
bike_s = bikes |> slice_sample(n = 100 )
census_api_key("9fc5d3792d3a5e922287c3f4e9995118766d50a2")
To install your API key for use in future sessions, run this function with `install = TRUE`.
v2018 = load_variables(2018, "acs5")
df_censcus=get_acs(geography = "tract",
variables=c("vehicles"="B08141_001",
"population" = "B01001_001",
"public_transportion" = "B08006_008"),
state="DC",geometry=TRUE,year=2021)
Getting data from the 2017-2021 5-year ACS
Downloading feature geometry from the Census website. To cache shapefiles for use in future sessions, set `options(tigris_use_cache = TRUE)`.
Using FIPS code '11' for state 'DC'
plot(df_censcus)

plot(racks)

tmap_mode("view")
tmap mode set to interactive viewing
df_cens=df_censcus %>%
select(-moe) %>%
pivot_wider(names_from = "variable",
values_from = "estimate")|>
mutate(pub_pop = public_transportion / population,
v_pop = vehicles / population)
bike_routes = st_read((here("data_raw", "Signed_Bike_Routes.geojson"))) |> clean_names()
Reading layer `Signed_Bike_Routes' from data source `C:\Users\thistljy\Documents\ds241_final\data_raw\Signed_Bike_Routes.geojson' using driver `GeoJSON'
Simple feature collection with 1024 features and 37 fields
Geometry type: LINESTRING
Dimension: XY
Bounding box: xmin: -77.08773 ymin: 38.8404 xmax: -76.92188 ymax: 38.98634
Geodetic CRS: WGS 84
df_cens_adj = df_cens |> st_transform(4326)
bike_routes = st_as_sf(bike_routes, crs=st_crs(df_cens_adj))
racks = st_as_sf(racks, crs=st_crs(df_cens_adj))
tm_shape(df_cens) +tm_polygons(c("pub_pop", "v_pop"), alpha=.5) + tm_shape(racks) +tm_symbols(size = 0.01, alpha = 0.5) +
tm_shape(bike_routes) + tm_lines(col="blue",lwd=1,alpha= 1)